#pragma once
#include "kernel_operator.h"
#include <cstdint>
template <typename T> struct SimpleStack {
  int64_t size_ = 0;
  __gm__ T *data_ = nullptr;
  __aicore__ inline SimpleStack() : size_(0) {}
  __aicore__ inline void init(GM_ADDR workspace) {
    data_ = (__gm__ T *)workspace;
    size_ = 0;
  }
  __aicore__ inline void push(T v) { data_[size_++] = v; }
  __aicore__ inline T pop() { return data_[--size_]; }
  __aicore__ inline bool empty() { return size_ == 0; }
  __aicore__ inline T top() { return data_[size_]; }
  __aicore__ inline void clear() { size_ = 0; }
};